#pragma once
#include <vector>
#include <SFML/Graphics.hpp>
#include "common.hpp"
#include <queue>
#include <memory>

struct peon;
struct square;
struct block;
struct job;

namespace en
{
    extern bool render;

    extern std::vector<peon*> peons;
    extern std::vector<square> squares;
    extern std::vector<block*> blocks;

    extern std::vector<sf::Texture> art_t;

    extern std::vector<std::shared_ptr<job>> jobs;
    extern std::vector<std::vector<std::shared_ptr<job>>> satisfying_peon_jobs;

    extern sf::RenderWindow win;

    extern pathable** collision_win;

    extern sf::Clock t;

    extern unsigned int state; ///pathfinding state still valid

    static std::vector<std::string> art_names = {"crew_q", "mess", "medical", "engineering", "cockpit", "shields", "armour", "engines", "lasers", "missiles", "ammo_major", "ammo_minor", "life_support", "wall", "wallv", "door", "doorv"};
    extern std::vector<std::vector<std::pair<std::string, float>>> trait_list;

    extern int w, h;

    void tick();
    void display();
    void clear();
    void save();
    void load();
    void add_job(std::shared_ptr<job>);

    void init();

    void assign_jobs();

    void load_traits();
    bool contains_trait(int n, std::string& str, int* pos=0);
    bool contains_trait(std::vector<std::pair<std::string, float>>& tlist, std::string& str, int* pos=0);
    bool contains_trait(std::vector<std::string>& tlist, std::string& str, int* pos=0);
    float get_val(std::vector<std::pair<std::string, float>>& tlist, std::string& str);
    int find_trait(std::vector<std::pair<std::string, float>>& tlist, std::string& str);

    extern float map_const_x, map_const_y;
};
